/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.StockDAOInterface;
import org.cuatrovientos.erp.model.Stock;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author eneko_lana
 * This class implements StockBOInterface
 */
public class StockBO implements StockBOInterface{
	// Get log4j logger
		private static final Logger logger = Logger.getLogger(StockBO.class);
		
		@Autowired
	    private StockDAOInterface StockDAO;
		
	/**
	 * @param int id
	 * @return Stock Stock
	 * This method returns a Stock selected by it's id
	 */
	@Override
	public Stock selectById(int id) {
		logger.info("selectById: " + id);
		return StockDAO.selectById(id);
	}
	
	/**
	 * @return All the countries we have in the database
	 */
	@Override
	public List<Stock> selectAll() {
		logger.info("selectAll: ");
		return StockDAO.selectAll();
	}
	
	/**
	 * @return The number of countries we have in the database
	 */
	@Override
	public List<Stock> search(String description) {
		logger.info("search : " + description);
		return StockDAO.search(description);
	}
	
	/**
	 * @param int id
	 * This method deletes the Stock selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		StockDAO.deleteById(id);
	}
	
	/**
	 * @param Stock Stock
	 * This method insert a Stock in the database passed by parameter
	 */
	@Override
	public void insert(Stock Stock) {
		logger.info("insert: " + Stock);
		StockDAO.insert(Stock);
	}
	
	/**
	 * @param Stock Stock
	 * This method updates a Stock passed by parameter
	 */
	@Override
	public void update(Stock Stock) {
		logger.info("update: " + Stock);
		StockDAO.update(Stock);
	}
	
	/**
	 * @param Stock role
	 * This method deletes a Stock passed by parameter
	 */
	@Override
	public void delete(Stock Stock) {
		logger.info("delete: " + Stock);
		StockDAO.delete(Stock);
	}

}
